﻿@using Smartstore.Admin.Models.Catalog

@model ProductOverviewModel

@{
	var parentModel = ViewData["Parent"] as RuleSetModel;
	var isSingleStoreMode = (bool)ViewData["IsSingleStoreMode"];
	var displayProductPictures = (bool)ViewData["DisplayProductPictures"];
}

<datagrid id="product-preview-grid" 
		allow-resize="true" 
		allow-column-reordering="true" 
		allow-row-selection="false" 
		preserve-grid-state="true"
		max-height="800px">
	<datasource read="@Url.Action("PreviewList", new { id = parentModel.Id })" />
	<paging position="Bottom" show-size-chooser="true" />
    <columns>
        @if (displayProductPictures)
        {
            <column for="PictureThumbnailUrl"
                    title=""
                    width="48px"
                    sortable="false"
                    visible="true"
                    readonly="true"
                    resizable="false"
                    reorderable="false">
                <display-template>
                    <div v-if="item.row.Id > 0" class="d-flex align-items-center justify-content-center" style="position: absolute; width: 100%; height: 100%; padding: 8px; left: 0; top: 0;">
                        <img :alt="item.row.Id" :src="item.value" style="max-width: 42px; max-height: 32px;" />
                    </div>
                </display-template>
            </column>
        }
        <column for="Id" halign="center" type="string" visible="false" />
        <column for="Name" width="3fr" hideable="false">
            <display-template>
                @Html.LabeledProductName(linkTarget: "_blank")
            </display-template>
        </column>
        <column for="Sku" />
        <column for="Price" halign="flex-end" />
        <column for="StockQuantity" halign="center" />
        @if (!isSingleStoreMode)
        {
            <column for="LimitedToStores" halign="center" />
        }
        <column for="CreatedOn" />
        <column for="UpdatedOn" />
        <column for="Published" halign="center" />
    </columns>
</datagrid>